export default Circle
import {c, mouse} from "./canvas";

// 圆
function Circle(x, y, radius, color) {
    this.x = x;
    this.y = y;
    this.radius = radius;
    this.color = color;

    this.update = function () {
        this.draw();
    };

    this.draw = function () {
        c.beginPath()
        c.arc(this.x, this.y, this.radius, 0, Math.PI * 2, false)
        let linear = c.createLinearGradient(this.x, this.y, mouse.x, mouse.y);
        linear.addColorStop(0, "white");
        linear.addColorStop(1, this.color);
        c.fillStyle = linear
        c.fill()
        c.closePath()
    };

    this.changePosition = function (x, y) {
        this.x = x;
        this.y = y;
    }
}